//
//  BaseModel.m
//  EPA
//
//  Created by lanou3g on 16/4/20.
//  Copyright © 2016年 浮夸. All rights reserved.
//

#import "BaseModel.h"
#import "TextModel.h"
#import "ImageModel.h"

@implementation LDTUserInfo

- (void)setValue:(id)value forKey:(NSString *)key{
    
    [super setValue:value forKey:key];
    
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}

@end



@implementation BaseModel

+ (instancetype)modelWithDictionary:(NSDictionary *)dictionary
{
 
    
    if ([dictionary[@"coverimg"] length] > 0) {
        ImageModel *imageModel = [ImageModel new];
        [imageModel setValuesForKeysWithDictionary:dictionary];
        return imageModel;
        
    }else{
        TextModel *textModel = [TextModel new];
        [textModel setValuesForKeysWithDictionary:dictionary];
        return textModel;
    }


}


- (void)setValue:(id)value forKey:(NSString *)key
{
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"userinfo"]) {
        self.userinfoModel = [LDTUserInfo new];
        [self.userinfoModel setValuesForKeysWithDictionary:value
         ];
    }
}



- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}


@end
